<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="__PUBLIC__/echarts/echarts.min.js"></script>
    <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all">
    <link rel="stylesheet" href="__CSS__/admin.css"  media="all">
</head>
<style>

    .layui-table th, .layui-table td{
        padding: 9px 6px;
        text-align: center;
    }
    .operation-menu a{
        margin: 5px 0;!important;
    }
    .layui-form-label-copy{
        float: left;
        display: block;
        padding: 9px 15px;
        font-weight: 400;
        line-height: 20px;
        text-align: right;
    }
</style>
<body>
<div class="layui-fluid main">
    <fieldset class="layui-elem-field site-demo-button" style="margin-top: 30px;border:0">
        <div class="layui-form-item" style="float: left;">
            <form class="layui-form serch" action="" method="post">
                <div class="layui-form-item" style="float: left;">

                    <a href="{:url('admin/custom/addconfig')}" class="layui-btn layui-btn-sm a_menu">
                        新建服务
                    </a>

                </div>
            </form>

        </div>
    </fieldset>

    <table class="layui-table" lay-even="" lay-skin="line">
        <colgroup>
            <col width="15%">
            <col width="7%">
            <col width="68%">
            <col width="10%">
        </colgroup>
        <thead>

        <tr>
            <th>服务项目</th>
            <th>服务类型</th>
            <th>服务内容</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        {volist name='data' id='vo'}
        <tr>
            <td>{$vo.title}</td>
            <td>{if($vo.customtype == 1)}个人定制{else/}企业定制{/if}</td>
            <td>
            {volist name='vo.answer' id='vod'}
                <span class="layui-btn layui-btn-normal">{$vod}</span>
            {/volist}
            </td>
            <td class="operation-menu">
                <a  class="layui-btn layui-btn-xs layui-btn-warm delete" codeid="{$vo.id}" style="margin-right: 0;font-size:12px;background: #51a954">删除</a>
                <a href="{:url('admin/custom/addconfig')}?id={$vo.id}" class="layui-btn layui-btn-xs layui-btn-warm a_menu"  style="margin-right: 0;font-size:12px;background: #FF5722">修改</a>
            </td>
        </tr>
        {/volist}
        </tbody>
    </table>

    <script src="__PUBLIC__/layui/layui.js"></script>
    <script src="__PUBLIC__/jquery/jquery.min.js"></script>

    <script>
        var message;
        layui.config({
            base: '__JS__/',
            version: '1.0.1'
        }).use(['app', 'message'], function() {
            var app = layui.app,
                $ = layui.jquery,
                layer = layui.layer;
            //将message设置为全局以便子页面调用
            message = layui.message;
            //主入口
            app.set({
                type: 'iframe'
            }).init();
        });
    </script>
    <script type="text/javascript">

        $('.delete').click(function(){
            var id = $(this).attr('codeid');
            layer.confirm('确定要删除?', function(index) {
                $.ajax({
                    url:"{:url('admin/custom/delconfig')}",
                    data:{id:id},
                    success:function(res) {
                        layer.msg(res.msg);
                        if(res.code == 1) {
                            setTimeout(function(){
                                location.reload();
                            },1500)
                        }
                    }
                })
            })
        })


    </script>
    <script type="text/javascript">
        layui.use('layer', function(){
            var layer = layui.layer;
            $('.a_menu').click(function(){
                var url = $(this).attr('href');
                var a = 0;
                $.ajax({
                    url:url
                    ,async:false
                    ,success:function(res){
                        if(res.code == 0) {
                            layer.msg(res.msg);
                            a = 1;
                        }
                    }
                })
                if(a === 0) {
                    layer.open({
                        type:2,
                        content:url,
                        area: ['700px', '680px'],
                        end:function(){
                            location.reload();
                        }
                    });
                }
                return false;
            })

            $('.preview').click(function(){
                var url = $(this).attr('href');
                layer.open({
                    type:2,
                    content:url,
                    area: ['550px', '400px']
                });
                return false;
            })
        });
    </script>

</body>
</html>
